package lianxi;

import java.util.Comparator;
import java.util.PriorityQueue;

public class demo8 {

    public class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

    class Solution {
        public ListNode reverseList(ListNode head) {
           if(head==null){
               return head;
           }
           ListNode reverse=null;
           ListNode curnode=head;
           while (curnode!=null){
               ListNode temp=curnode.next;
               curnode.next=reverse;
               reverse=curnode;
               curnode=temp;
           }
           return reverse;
        }

    }
}
